// 基类 鞋子
class Shoes
{
public:
    virtual void Show() = 0;
    virtual ~Shoes() {}

    static Shoes *New(const string &type)
    {
        if(shoesMap->find(type) == shoesMap->end())
        {
            cout << "unKnown type " << type << endl;
            return nullptr;
        }
        else
        {
            return (*shoesMap)[type]; 
        }
    }

    static void initMap()
    {
        static bool map_existed = false;
        if(!map_existed)
        {
            shoesMap = new unordered_map<string, Shoes*>;
            map_existed = true;
        }
    }  
    static void insertMap(const string &name, Shoes* obj)
    {
        shoesMap->insert(make_pair(name, obj));
    }
private:
    static unordered_map<string, Shoes*> *shoesMap;
};

unordered_map<string, Shoes*> * Shoes::shoesMap = nullptr;

// 耐克鞋子
class NiKeShoes : public Shoes
{
public:
    static const string typeName;
    void Show() override
    {
        std::cout << "我是耐克球鞋，我的广告语：Just do it" << std::endl;
    }
};
const string NiKeShoes::typeName = "nike";

